$OpenBSD: patch-qmake_generators_unix_unixmake2_cpp,v 1.19 2016/12/26 08:55:05 zhuk Exp $
1. Add support for OpenBSD shared libraries policy.
2. Add support for LOCALBASE.
--- qmake/generators/unix/unixmake2.cpp.orig	Fri Feb  2 17:01:27 2007
+++ qmake/generators/unix/unixmake2.cpp	Mon Dec 26 11:13:01 2016
@@ -129,6 +129,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
 	 src_incremental=FALSE, moc_incremental=FALSE;
 
     t << "####### Compiler, tools and options" << endl << endl;
+    if (varGlue("INCLUDEPATH", " -I", " -I", "").find("$(LOCALBASE)") != -1)
+    	t << "LOCALBASE?= /usr/local" << endl;
     t << "CC       = ";
     if (project->isActiveConfig("thread") &&
 	! project->variables()["QMAKE_CC_THREAD"].isEmpty())
@@ -295,10 +297,15 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
     } else if (!project->isActiveConfig("staticlib") && project->variables()["QMAKE_APP_FLAG"].isEmpty()) {
 	t << "TARGETA	= " << var("TARGETA") << endl;
 	if (project->isEmpty("QMAKE_HPUX_SHLIB")) {
-	    t << "TARGETD	= " << var("TARGET_x.y.z") << endl;
-	    t << "TARGET0	= " << var("TARGET_") << endl;
-	    t << "TARGET1	= " << var("TARGET_x") << endl;
-	    t << "TARGET2	= " << var("TARGET_x.y") << endl;
+  	    if (!project->isEmpty("QMAKE_OPENBSD_SHLIBS")) {
+		t << "LIB"+var("OBSD_TARGET_NAME")+"_VERSION = " << var("OBSD_TARGET_VERSION") << endl;
+  		t << "TARGETD	= " << var("TARGET_x.y") << endl;
+ 	    } else {
+		t << "TARGETD	= " << var("TARGET_x.y.z") << endl;
+		t << "TARGET0	= " << var("TARGET_") << endl;
+		t << "TARGET1	= " << var("TARGET_x") << endl;
+		t << "TARGET2	= " << var("TARGET_x.y") << endl;
+	    }
 	} else {
 	    t << "TARGETD	= " << var("TARGET_x") << endl;
 	    t << "TARGET0	= " << var("TARGET_") << endl;
@@ -375,6 +382,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
     }
 
     t << "####### Build rules" << endl << endl;
+    t << "$(OBJECTS): $(UICDECLS)" << endl << endl;
     if(!project->variables()["SUBLIBS"].isEmpty()) {
 	QString libdir = "tmp/";
 	if(!project->isEmpty("SUBLIBS_DIR"))
@@ -561,6 +569,17 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
 	    if(!project->isEmpty("QMAKE_POST_LINK"))
 		t << "\n\t" << var("QMAKE_POST_LINK") << "\n\t";
 	    t << endl << endl;
+        } else if (!project->isEmpty("QMAKE_OPENBSD_SHLIBS")) {
+	    t << "\n\t"
+	      << "-$(DEL_FILE) $(TARGET)" << "\n\t"
+	      << var("QMAKE_LINK_SHLIB_CMD") << "\n\t";
+	    if(!destdir.isEmpty())
+		t << "\n\t"
+		  << "-$(DEL_FILE) " << var("DESTDIR") << "$(TARGET)\n\t"
+		  << "-$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) " << var("DESTDIR");
+	    if(!project->isEmpty("QMAKE_POST_LINK"))
+		t << "\n\t" << var("QMAKE_POST_LINK");
+	    t << endl << endl;
 	} else if(project->isEmpty("QMAKE_HPUX_SHLIB")) {
 	    t << "\n\t"
 	      << "-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)" << "\n\t"
@@ -1293,10 +1312,20 @@ void UnixMakefileGenerator::init2()
 		project->variables()["TARGET_x"].append("lib" + project->first("TARGET") + "." +
 							project->first("QMAKE_EXTENSION_SHLIB") +
 							"." + project->first("VER_MAJ"));
-		project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
-						      project->first("QMAKE_EXTENSION_SHLIB")
-						      + "." + project->first("VER_MAJ") +
-						      "." + project->first("VER_MIN"));
+		if ( !project->variables()["QMAKE_OPENBSD_SHLIBS"].isEmpty() ) {
+		    QString s;
+		    s.setNum(project->first("VER_MIN").toInt()*10+ project->first("VER_PAT").toInt());
+		    project->variables()["OBSD_TARGET_VERSION"].append(project->first("VER_MAJ") + "." + s);
+		    project->variables()["OBSD_TARGET_NAME"].append(project->first("TARGET"));
+		    project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
+							  project->first("QMAKE_EXTENSION_SHLIB")
+							  + ".$(LIB"+ project->first("TARGET") + "_VERSION)");
+		} else {
+		    project->variables()["TARGET_x.y"].append("lib" + project->first("TARGET") + "." +
+							  project->first("QMAKE_EXTENSION_SHLIB")
+							  + "." + project->first("VER_MAJ") +
+							  "." + project->first("VER_MIN"));
+		}
 		project->variables()["TARGET_x.y.z"].append("lib" + project->first("TARGET") +
 							    "." +
 							    project->variables()[
@@ -1305,7 +1334,10 @@ void UnixMakefileGenerator::init2()
 							    project->first("VER_MIN") +  "." +
 							    project->first("VER_PAT"));
 	    }
-	    project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
+	    if ( !project->variables()["QMAKE_OPENBSD_SHLIBS"].isEmpty() )
+		project->variables()["TARGET"] = project->variables()["TARGET_x.y"];
+	    else
+		project->variables()["TARGET"] = project->variables()["TARGET_x.y.z"];
 	}
 	if(project->isEmpty("QMAKE_LN_SHLIB"))
 	    project->variables()["QMAKE_LN_SHLIB"].append("ln -s");
@@ -1586,5 +1618,6 @@ UnixMakefileGenerator::writePkgConfigFile()     // ###
       << varGlue("PRL_EXPORT_DEFINES","-D"," -D"," ")
       << project->variables()["PRL_EXPORT_CXXFLAGS"].join(" ")
 	//      << varGlue("DEFINES","-D"," -D"," ")
-      << " -I${includedir}";
+      << " -I${includedir}"
+      << endl;
 }
